<template>
<el-dialog title="选择病种" :visible.sync="visible" width="300px" :close-on-click-modal="false" :close-on-press-escape="false">
  <div class="wt-patient-id-input">
		<ill-type-select v-model="illType" :loading.sync="loading"></ill-type-select>
	</div>
	
  <div slot="footer" class="dialog-footer">
    <el-button @click="cancel">取 消</el-button>
    <el-button type="primary" @click="ensure" :disabled="loading || !illType">确 定</el-button>
  </div>
</el-dialog>
	
</template>
<script>
/**
 *
 * Events:
 *	select 当确定患者信息时触发
 */
import AutoComplete from "winged/components/wt-autocomplete";
import illTypeSelect from "./ill-type-select";

export default {
	name: "select-to-create-case",
	props: {
		value: String,
		disabled: {
			type: Boolean,
			default: false
		},
		visible: {
			type: Boolean,
			default: false
		}
	},
	components: {
		[illTypeSelect.name]: illTypeSelect
	},
	data() {
		return {
			illType: this.value, //病种,
			loading: false
		};
	},
	watch: {
		value(val, oldValue) {
			this.setCurrentValue(val);
		}
	},
	methods: {
		cancel() {
			this.$emit("update:visible", false);
			history.go(-1);
		},
		ensure() {
			this.$emit("update:visible", false);
			this.$emit("input", this.illType);
		},
		itemInfoDisplay(item) {
			return item.patientName;
		},
		setCurrentValue(value) {
			if (value === this.illType) return;
			this.illType = value;
		},
		handleInput(val) {
			this.$emit("input", val);

			// 刷新查询状态的功能目前还未调通，因为span的message会出现换行现象还未解决。
			/*
				let _this = this;
				Vue.nextTick(() => {
					_this.checkLoadingStatus();
				});*/
		},
		handleSelect(data) {
			this.$emit("select", data);
		},
		// 检查患者信息的查询状态并且显示对应信息。
		checkLoadingStatus() {
			// 刷新查询状态的功能目前还未调通，因为span的message会出现换行现象还未解决。
			/* 
				if (this.$refs.input.isLoading) {
					this.message = `正在查询病案号'${this.illType}'的患者信息`;
				}
				else {

				}*/
		}
	},
	created() {}
};
</script>